/**
 * @User: vitobo
 * @Date: 2024-06-11
 * @Description:
 */

class Food{

}
class Fruit extends Food{

}
class Apple extends Fruit{

}
class Banana extends Fruit{

}

class Plate<T>{
    private T plate;
    public T getPlate(){
        return plate;
    }
    public void setPlate(T plate){
        this.plate = plate;
    }
}


public class Test4 {

    public static void fun(Plate<? super Fruit> temp){
        temp.setPlate(new Apple());
        temp.setPlate(new Banana());
        temp.setPlate(new Fruit());

    }

    public static void main(String[] args) {
        Plate<Apple> plate1 = new Plate<>();
        plate1.setPlate(new Apple());
        fun1(plate1);

        Plate<Banana> plate2 = new Plate<>();
        plate2.setPlate(new Banana());
        fun1(plate2);
    }


    // 通配符上界
    public static void fun1(Plate<? extends Fruit> tmp){
        Fruit fruit = tmp.getPlate();
    }

    public static void main1(String[] args) {
        Plate<Apple> plate1 = new Plate<>();
        plate1.setPlate(new Apple());
        fun1(plate1);

        Plate<Banana> plate2 = new Plate<>();
        plate2.setPlate(new Banana());
        fun1(plate2);
    }
}
